import asyncio

"""
    方式三：python 3.4 的写法，现在已经弃用,能够运行，但是会有报错
"""
@asyncio.coroutine
def hello():
    print("1")
    yield from asyncio.sleep(1)
    print("2")


@asyncio.coroutine
def wget():
    print('3')
    yield from asyncio.sleep(1)
    print('4')


tasks = [
    asyncio.ensure_future(hello()),
    asyncio.ensure_future(wget())
]

loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(tasks))